#!/usr/bin/env python
#coding:utf-8

from os.path import walk, join, normpath
from os import chdir, remove

def scan(arg, dirname, names):
    for file in names:
        if file[-1] == '~' or file[-4:] == '.bak':
            files = normpath(join(dirname, file))
            chdir(dirname)
            print "deleting",files
            remove(file)
            print "done!"

if __name__ == '__main__':
    path = chdir('/home/wyatt/wlife')
    walk(path, scan, 0)
